# 1、实现一个timeit的装饰器：timeit 装饰能够计算被装饰函数的运行时间
from datetime import datetime
import time
def timer(fn):
    def reg(*args,**kwargs):
        start = datetime.now()
        res = fn(*args,**kwargs)
        needTime = (datetime.now() - start).total_seconds()
        msg = "函数返回值为：{},运行总时常为：{:0.2f}".format(res,needTime)
        print(msg)
    return reg
@timer
def add(x,y):
    time.sleep(3)
    return x+y

add(4,y=55)







